<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions" >
<h:head>
	<title>List Travel Packages</title>
</h:head>
<h:body>
	<h:link value="PERSONAL HOME" outcome="index" />
	<h:form id="formSearch">
		<p:panel header="Travel package search">
		<h:panelGrid columns="2">
			<p:outputLabel for="keyword" value="Keyword: " />
			<p:inputText id="keyword" value="#{listCustomerTravelPackages.keywordSearch}" label="Keyword" />
		
			<p:outputLabel value="Search type " />  
        	<p:selectOneMenu value="#{listCustomerTravelPackages.typeSearch}">  
    			<f:selectItems value="#{listCustomerTravelPackages.searchTypes}" /> 
        	</p:selectOneMenu> 
		
      		<p:commandButton value="Submit" update="@form" action="#{listCustomerTravelPackages.search()}" />
      	</h:panelGrid>
      	<br />
      	<p:dataTable id="dataTablePackageSearch" var="package" value="#{listCustomerTravelPackages.travelPackagesSearch}"  
                 paginator="true" rows="15"
                 paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink}
                 {PageLinks} {NextPageLink} {LastPageLink}" >
     	
        <p:ajax event="rowSelect" listener="#{listCustomerTravelPackages.onTravelPackageRowSelectNavigate}" />
        
        <f:facet name="header">  
            Search result
        </f:facet>  
  
        <p:column sortBy="id" headerText="ID">  
            <h:outputText value="#{package.id}" />  
        </p:column>  
  
        <p:column headerText="Description">
            <p:inputTextarea value="#{package.description}" rows="2" cols="15"
            	readonly="true" autoResize="false" />   
        </p:column>  
  
        <p:column sortBy="startTrip" headerText="Begin date">
            <h:outputText value="#{package.startTrip}" >
            	<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
            </h:outputText>  
        </p:column>
        
         <p:column sortBy="endTrip" headerText="End date">
            <h:outputText value="#{package.endTrip}" >
            	<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
            </h:outputText>  
        </p:column>
        
        <p:column sortBy="price" headerText="Total price">
            <h:outputText value="#{package.totalPrice} €" />  
        </p:column>
        
        <p:column sortBy="expiryDate" headerText="Expiry">
            <h:outputText value="#{package.expiry}" >
            	<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
            </h:outputText>  
        </p:column>
        
        <p:column sortBy="feasibleReservations" headerText="Feasible reservations">
            <h:outputText value="#{package.feasibleReservations}" />  
        </p:column>
        
        <p:column sortBy="type" headerText="Type">
            <h:outputText value="#{package.type}" />  
        </p:column>
        <f:facet name="footer">  
              Total travel packages: #{listCustomerTravelPackages.travelPackagesSearch.size()}
        </f:facet>
    	</p:dataTable>
    	</p:panel>
	</h:form>
	
 	<h:form id="formView">
		<f:event type="preRenderView" listener="#{listCustomerTravelPackages.init()}" />
	
        <p:dataTable id="dataTablePackage" var="package" value="#{listCustomerTravelPackages.travelPackages}"  
                 paginator="true" rows="15" rowKey="#{package.id}" 
                 selectionMode="single" selection="#{listCustomerTravelPackages.selectedTravelPackage}"
                 paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink}
                 {PageLinks} {NextPageLink} {LastPageLink}" >
     	
        <p:ajax event="rowSelect" listener="#{listCustomerTravelPackages.onTravelPackageRowSelectNavigate}" />
        
        <f:facet name="header">  
            List available travel packages
        </f:facet>  
  
        <p:column sortBy="id" filterBy="id" headerText="ID"
        	filterMatchMode="contains" >  
            <h:outputText value="#{package.id}" />  
        </p:column>  
  
        <p:column headerText="Description">
            <p:inputTextarea value="#{package.description}" rows="2" cols="15"
            	readonly="true" autoResize="false" />   
        </p:column>  
  
        <p:column sortBy="startTrip" headerText="Begin date">
            <h:outputText value="#{package.startTrip}" >
            	<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
            </h:outputText>  
        </p:column>
        
         <p:column sortBy="endTrip" headerText="End date">
            <h:outputText value="#{package.endTrip}" >
            	<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
            </h:outputText>  
        </p:column>
        
        <p:column sortBy="price" headerText="Total price">
            <h:outputText value="#{package.totalPrice} €" />  
        </p:column>
        
        <p:column sortBy="expiryDate" headerText="Expiry">
            <h:outputText value="#{package.expiry}" >
            	<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT+1"/>
            </h:outputText>  
        </p:column>
        
        <p:column sortBy="feasibleReservations" headerText="Feasible reservations">
            <h:outputText value="#{package.feasibleReservations}" />  
        </p:column>
        
        <p:column sortBy="type" headerText="Type">
            <h:outputText value="#{package.type}" />  
        </p:column>
        <f:facet name="footer">  
              Total travel packages: #{listCustomerTravelPackages.travelPackages.size()}
        </f:facet>
    	</p:dataTable>
	</h:form>
</h:body>
</html>